Skip to main content

C Program to take input from the user.

→ Program to take input from the user- integer, char, string, decimal, and to print all values.

#include<stdio.h>

int main()
{

  int a;

  char b;

  char c[10];

  float d;

  printf("Enter interger value:");

  scanf("%d",&a);

  printf("\nEnter a character:");

  scanf(" %c",&b);

  printf("\nEnter a name:");

  scanf("%s",&c);

  printf("\nEnter decimal value:");

  scanf("%f",&d);

  printf("\nInterger value is %d ",a);

  printf("\nYour Character is %c ",b);

  printf("\nGiven name is %s ",c);

  printf("\nDecimal value is %f ",d);

  return 0;

}

Comments

  1. Hello Arbaz . Very helpful content. Please keep making new posts. And add description after important coding lines so that we can know exactly what each line does.

    ReplyDelete
  2. Thanks Lengdon for your valuable feedback.
    Sure I will add description after important coding lines.

    ReplyDelete

Post a Comment

Popular posts from this blog

A simple calculator program.

→ A simple calculator using C language. In this, you can add, multiply, divide and subtract any two number. #include<stdio.h> int main() {    float a,b,c;    char d;    printf("Enter:");    scanf("%f  %c %f",&a,&d,&b);    if(d=='+')    {     c=a+b;     printf("%.2f",c);    }    else if(d=='-')    {     c=a-b;     printf("%.2f",c);    }    else if(d=='*')    {     c=a*b;     printf("%.2f",c);    }    else if(d=='/')    {     c=a/b;     printf("%.2f",c);    } } Output: Enter:  9/4              2.25

C program to print Mario game Pyramid .

#include<stdio.h> #include<cs50.h> int main() {     int n ; //declaring a n variable     int i, j, k;     do      //do while loop     {         n = get_int("Height: "); //taking input from the user     }     while (n < 1 || n > 8); //checking condition     for (i = 1; i <= n; i++) //for loop for printing pyramid of blocks     {         for (j = i; j < n; j++)         {             printf(" ");         }         for (k = 1; k <= i; k++)         {             printf("#");         }         printf("  ");         for (k = 1; k <= i; k++)         {             printf("#");  ...