c questions....
1.Give explanation along with output:
main()
{
int a[]={2.9,3.6,8,9.7,5.8};
int j,*q=a;
for(int i=0;j<5;j++)
{
printf("\t%d",*c);
++*q;
}
}
2.
main()
{
int i=-1;
+i; //i dont know what does +i signify here,this is the only problem in this question
printf("%d %d"i,+i);
}
3.
main()
{
print("hiiiiiiii");
main();
}
a.hiiiiiiii b.compiler error c.hiiiiiiii hiiiiiiiiiiiii hiiiiiiiiiiiiii............stack overflow d.undefined results
4.printf("xy","ab","mn");
it will print??
a.xy b.xyabmn c.garbage value d.it will give error
5.main()
{
printf(5+"intelligent");
}
6.main()
{
int a[5]={1,2,3,4,5};
int *ptr=(int*)(&a+1);
printf("%d %d",*(a+1),*(ptr-1));
}
a.2 2 b.2 5 c.2 1 d.none
main()
{
int a[]={2.9,3.6,8,9.7,5.8};
int j,*q=a;
for(int i=0;j<5;j++)
{
printf("\t%d",*c);
++*q;
}
}
2.
main()
{
int i=-1;
+i; //i dont know what does +i signify here,this is the only problem in this question
printf("%d %d"i,+i);
}
3.
main()
{
print("hiiiiiiii");
main();
}
a.hiiiiiiii b.compiler error c.hiiiiiiii hiiiiiiiiiiiii hiiiiiiiiiiiiii............stack overflow d.undefined results
4.printf("xy","ab","mn");
it will print??
a.xy b.xyabmn c.garbage value d.it will give error
5.main()
{
printf(5+"intelligent");
}
6.main()
{
int a[5]={1,2,3,4,5};
int *ptr=(int*)(&a+1);
printf("%d %d",*(a+1),*(ptr-1));
}
a.2 2 b.2 5 c.2 1 d.none
Replies
-
techworm
1) in this question compiler will give 2 errorsneha11.Give explanation along with output:
main()
{
int a[]={2.9,3.6,8,9.7,5.8};
int j,*q=a;
for(int i=0;j<5;j++)
{
printf("\t%d",*c);
++*q;
}
}
2.
main()
{
int i=-1;
+i; //i dont know what does +i signify here,this is the only problem in this question
printf("%d %d"i,+i);
}
3.
main()
{
print("hiiiiiiii");
main();
}
a.hiiiiiiii b.compiler error c.hiiiiiiii hiiiiiiiiiiiii hiiiiiiiiiiiiii............stack overflow d.undefined results
4.printf("xy","ab","mn");
it will print??
a.xy b.xyabmn c.garbage value d.it will give error
5.main()
{
printf(5+"intelligent");
}
6.main()
{
int a[5]={1,2,3,4,5};
int *ptr=(int*)(&a+1);
printf("%d %d",*(a+1),*(ptr-1));
}
a.2 2 b.2 5 c.2 1 d.none
a) undefined variable c //if c is replaced by a it makes sense
b)array of integers is assigned values in float
2) here + is used as a unary operator
3)compiler error print function undeclared
if u correct this error then c is the correct ans
4)here the output is "ligent"
this syntax indicates that the output should print the string from 5th character counting from 0
5)here ans is b)2,5
for *(a+1) indicates a[0][1] which is 2 here.
ptr contains the address of the memory location after the array..as it is (&a)+1...not &(a+1)..
as ptr is an int pointer so ptr-1...indicates the location of the last element of the array..
so *(ptr-1) is 5(the last element of the array)
accordng to me these are the answers
i hope you got all the ans..
in case u have not...feel free to ask again😀 -
ankesh.cs2007hay neha nice set of questions.
i agree with tech worm.
he had forgot to answer q4
ans is it will print xyabmn -
techwormyeah...i missed that one....
@ankesh but my compiler is giving the result as 'xy', even i cant understand the exact reason😕 -
chaandsheikh#include
const char g_szClassName[] = "myWindowClass";
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
//Step 1: Registering the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Step 2: Creating the Window
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
// Step 3: The Message Loop
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
Hi its Chaand from Nagpur
The above is a simple windows program
#-Link-Snipped-#
I want a button in this window which will link to another window say the name of that button is Next
Also How can i write some Text on that window which can be copied and paste say on notepad.
Please Explain -
neha1Hey......thanx Techworm....i got all the answers
wel what about 4th question..??
its output is xy only...why its so??please explain..... -
gaurav.bhorkarneha1Hey......thanx Techworm....i got all the answers
wel what about 4th question..??
its output is xy only...why its so??please explain.....4.printf("xy","ab","mn");
The syntax of printf is
it will print??
a.xy b.xyabmn c.garbage value d.it will give error
printf ("<%format_specifiers>", variable, variable....);
If you say printf ("xy", "ab", "mn"), then only xy is printed because you haven't specified the format specifier. The first argument passed to printf contains format specifiers and text, while all other arguments correspond to the format specifiers.
For example, the output of printf ("Crazy %d") would be "Crazy".
whereas, the output of printf ("crazy %d", i) would be "Crazy"
Try putting printf ("xy %s %s", "ab", "mn"), the output will be "xy ab mn".
You may argue that "ab" and "mn" aren't variables but strings. Ofcourse they are strings but, when passing arguments to a function always the base address of strings are passed not the whole string, and this base address is stored in a variable. So ultimately you are a passing a variable (base address). -
neha1thanks gaurav...i do agree with you...
You are reading an archived discussion.
Related Posts
can any one have idea about buffer overflows in sql environment.
.😒
If you think you can't produce great art with your mouse, IOgraph will change your opinion. What the application does is record your mouse movements and create an art out...
For B.Tech (4 years) Course
Aerospace Engineering
Agricultural and Food Engineering
Chemical Engineering
Computer Science & Engineering
Electrical Engineering
Mechanical Engineering
Metallurgical Engineering and Material Science
Do you know which...
For B.Tech (4 years) Course
Chemical Engineering
Civil Engineering
Computer Science & Engineering
Electrical Engineering
Electrical Engineering (Power)
Mechanical Engineering
Production and Industrial Engineering
Textile Technology
Do you know which...
For B.Tech (4 years) Course
Biotechnology
Chemical Engineering
Civil Engineering
Computer Science & Engineering
Electronics & Communication Engineering
Engineering Physics
Mathematics & Computing
Mechanical Engineering
Do you know which of...