Assuming you're using the C Programming language (as you did not specify any other), and that you're making some sort of arithmetic tester, a simple answer would be:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
time_t seconds;
time(&seconds);
srand((unsigned int)seconds);
int num1 = (rand()%100);
int num2 = (rand()%100);
int sum = num1 + num2;
int ans;
printf("What is %d + %d? ", num1, num2);
scanf("%d", &ans);
if(ans == sum) printf("Correct!");
else printf("Wrong, correct answer is %d", sum);
return 0;
}
Chat with our AI personalities
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,sum;
printf("Enter first number ");
scanf("%d",&a);
printf("Enter second number ");
scanf("%d",&b);
sum=a+b;
printf("The sum is = %d ",sum);
getch();
}
Write a program to sum a sequence of integers between two numbers that are entered by user. The program does not include the numbers that can be divided by 10 to total sum. Note: you should use continue control statement and you can control division by 10 using mod operator like i %10
To write a C++ program to display the student details using class and array of object.
you do this 10 print "0112358132134" use the whole of the thing
identification division. program-id. greatest. environment division. data division. working-storage section. 77 a pic 999. 77 b pic 999. 77 c pic 999. procedure division. greatest. display "ENTER THE THREE NUMBERS:". accept a. accept b. accept c. if a > b and a > c display a "is greatest" else if b > c display b "is greatest" else display c "is greatest". display " thank you". stop run.
Write a program which takes the temperature in farhenheight.the program should display the farhenheight temperature as well as centigrade. C= (f-32)*5/9
A C++ program can be used to write C programs that will display 10 lines of biodata. Many types of C programming can be written with a C++ program.