Write a C program to add two numbers before the main function
is called.
Answers were Sorted based on User's Feedback
Answer / deepjot kaur
void AddTwoNumbers();
#pragma startup AddTwoNumbers
void main()
{
printf("\n Executing Main...");
}
void AddTwoNumbers()
{
int num1,num2 = 0;
printf( "\nEnter number 1 : ");
scanf( "%d", &num1 );
printf( "\nEnter number 2 : ");
scanf( "%d", &num2 );
printf( "\nThe sum is = %d..." ,(num1 + num2) );
}
Is This Answer Correct ? | 45 Yes | 29 No |
Answer / boss
Answer#1 above by Deepjot Kaur is the ONLY CORRECT ANSWER
Here. Pls ignore all others. They Posters did not understood
the Question basically.
The Qn is: We need to write a program in which there is one
main and a function. When executed, Function should run
first and then the Main().
Is This Answer Correct ? | 10 Yes | 3 No |
Answer / sheenu
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter the value");
scanf("%d%d",&a,&b);
c=a+b;
printf("%d",c);
getch();
}
Is This Answer Correct ? | 8 Yes | 5 No |
Answer / govind verma
but #prgma does not support on gcc... so this code is run only turbo c ......
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / naveen
#include <stdio.h>
#include <conio.h>
void main();
{
int a,b,c;
scanf("%d%d", &a,&b);
printf("enter a two numbers \n");
c=a+b;
printf("The add of two numbers are %d ",c);
clrscr();
getch();
}
Is This Answer Correct ? | 6 Yes | 5 No |
Answer / salini
#include<stdio.h>
void main()
{
int a,b,c;
printf("Enter the first number :");
scanf("%d \n",&a);
printf("Enter the second number :");
scanf("%d \n",&b);
c=a+b;
printf("The addition of %d and %d is %d",&a,&b,&c);
}
Is This Answer Correct ? | 3 Yes | 5 No |
#include <stdio.h>
int func()
{
int a = 10;
int b = 20;
printf("\nExecuting func FIRST...\n");
printf("Sum of the two numbers is %d", (a + b));
return (a + b);
}
int x = func();
int main(int argc, char* argv[])
{
printf("\nExecuting Main LAST...\n");
return 0;
}
Is This Answer Correct ? | 12 Yes | 15 No |
Answer / nirmal bhattarai
#include<stdio.h>
#include<conio.h>
void main()
{
rintf("\n Executing Main...");
}
void AddTwoNumbers()
{
int num1,num2 = 0;
printf( "\nEnter number 1 : ");
scanf( "%d", &num1 );
printf( "\nEnter number 2 : ");
scanf( "%d", &num2 );
printf( "\nThe sum is = %d..." ,(num1 + num2) );
}
get();
}
Is This Answer Correct ? | 1 Yes | 4 No |
Answer / b.vinod
#include<stdio.h>
main()
{
int a,b,c;
printf("Enter the value a,b");
scanf("%d%d",&a,&b);
c=a+b;
printf("c value is%d",a);
}
Is This Answer Correct ? | 11 Yes | 27 No |
Answer / divya prabhu
#include<stdio.h>
#include<conio.h>
void add()
{
int a,b,c;
printf("\n Enter the two numbers to be added:");
scanf("%d %d",&a,&b);
c=a+b;
printf("\n The addition of two entered numbers is: %
d",c);
}
void main()
{
clrscr();
add();
getch();
}
Is This Answer Correct ? | 12 Yes | 31 No |
program to find the roots of a quadratic equation
14 Answers College School Exams Tests, Engineering, HP, IIIT, Infosys, Rajiv Gandhi University of Knowledge Technologies RGUKT, SSC,
#define prod(a,b) a*b main() { int x=3,y=4; printf("%d",prod(x+2,y-1)); }
what will be the position of the file marker? a: fseek(ptr,0,SEEK_SET); b: fseek(ptr,0,SEEK_CUR);
struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above
main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }
Printf can be implemented by using __________ list.
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
Is it possible to type a name in command line without ant quotes?
void main() { int const * p=5; printf("%d",++(*p)); }
3 Answers Infosys, Made Easy, State Bank Of India SBI,
#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }
void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!