Search

Simple Programs

 

C program to read roll number and marks from user and display it on screen.



 This program shows how to declare and use int variables. Read roll number and marks from user and display it on screen.


#include<stdio.h>
int main()
{
int marks,rollno;

printf("Enter your Roll No:");
scanf("%d", &rollno);

printf("Enter your Marks:");
scanf("%d", &marks);

printf("Your Roll No: %d.\n", rollno);
printf("Your marks: %d", marks);
return 0;
}

Output of the program

Enter your Roll No:101
Enter your Marks:70
Your Roll No: 101.
Your marks: 70



Simple Calculator using C

/*Simple Calculator using C. 
Addition, Subtraction, Multiplication, and Division.
*/
#include<stdio.h>
void main()
{
   int number1, number2;

   printf("Enter number1:");
   scanf("%d",&number1);

   printf("Enter number2:");
   scanf("%d",&number2);

   printf("Addition of two numbers: %d\n", number1 + number2 );
   printf("Substraction of two numbers: %d\n", number1 - number2 );
   printf("Multiplication of two numbers: %d\n", number1 * number2 );
   printf("Division of two numbers: %d\n", number1 / number2 );
}


Output of the program

Enter number1:10
Enter number2:5
Addition of two numbers: 15
Substraction of two numbers: 5
Multiplication of two numbers: 50
Division of two numbers: 2

No comments:

Post a Comment