Write a program to accept the values of two variables in C
Answers
Answered by
2
Answer:
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
clrscr();
printf("Enter number 1: ");
scanf("%d",&a);
printf("Enter number 2: ");
scanf("%d",&b);
c=a+b;
printf("Addition is : %d",c);
getch();
}
Answered by
0
The code to execute the given task to accept the values of two variables in C is as follows:-
#include <stdio.h>
int main() {
int n1;
int n2;
printf("Enter the number 1:\n");
scanf("%d", &n1);
printf("Enter the number 2:\n");
scanf("%d", &n2);
printf("Number 1: %d\n", n1);
printf("Number 2: %d\n", n2);
return 0;
}
- First, we declare two variables with the names 'n1' and 'n2'.
- scanf is an in-built C function which is used to take input from the user.
- We take the values as input from the user in variables n1 and n2.
- We then print the values stored in the variables n1 and n2 using printf function.
#SPJ3
Similar questions