Professional Documents
Culture Documents
C Variable
C Variable
C Variable
#include <stdio.h>
int main()
int myNum;
return 0;
//Write a program to take multiple input from user and print it.
#include <stdio.h>
int main()
return 0;
}
//Write a program to create an integer variable and print it.
#include <stdio.h>
int main()
int myNum = 15; //create an integer variable myNum, and assign value to it.
return 0;
}
//Write a program to add a variable to another variable and print it.
#include <stdio.h>
int main()
printf("%d", sum); // get the output from the value stored in the variable.
return 0;
}
//Write a program to declare many variable of same type separated by comma and print it.
#include <stdio.h>
int main()
int x = 5, y = 6, z = 50;
printf("%d", x + y + z);
return 0;
}
//Write a program to assign a constant value to a variable which cannot be changed.
#include <stdio.h>
int main()
printf("%d", BIRTHYEAR);
return 0;
}
//Write a program using %c for char and %f for float and printing output.
#include <stdio.h>
int main()
// Create variables
// Print variables
printf("%d\n", myNum);
printf("%f\n", myFloatNum);
printf("%c\n", myLetter);
return 0;
}
//Write a program to combine both text and variable and printing it output.
#include <stdio.h>
int main()
{
int myNum = 5;
printf("My favorite number is: %d", myNum);
return 0;
}
//Write a program to print different types in a single printf() function
#include <stdio.h>
int main()
{
int myNum = 5;
char myLetter = 'D';
printf("My number is %d and my letter is %c", myNum, myLetter);
return 0;
}