Monday, September 20, 2010
after every successfull execution of 'C' program what will happen?
After every successfull execution of a "C"-Program, main() returuns 0 to operating system, to tell that the program is executed successfully....
why we use getch() in main(), to get output?
getch() is a function call : it reads in a single character and waits for the user to hit enter before reading the character. This line is included before the end of the main() because many compiler environments will open a new console window, run the program, and then close the window before you can see the output. This command keeps that window from closing because the program is not done yet because it waits for you to hit enter. Including that line gives us time to see the program run.
Thursday, September 16, 2010
Wednesday, September 15, 2010
Write program which executes a function(main or any function) to infinite times without any iteration and conditional statements.
There only two ways to execute program to infinite number of times:
1. Using iteration or conditional statement.
2.Recursive functuion-function calls itself.
So,if iteration or conditional statement are not used, then recursive is another go...using recursive function we can write main() function as follows.
1. Using iteration or conditional statement.
2.Recursive functuion-function calls itself.
So,if iteration or conditional statement are not used, then recursive is another go...using recursive function we can write main() function as follows.
main()
{
printf("Hello world\n");
main();
}
{
printf("Hello world\n");
main();
}
Output:
Hello world is printed infinte number of times, till u break the program.
Write printf() and scanf() statement without semi-colon(;)
Print statement:
main()
{
int a;
clrscr();
if(scanf("%d",&a))
{}
if(printf("%d"),a)
{}
}
output:
2
2
Here in output,i entered 2 is given as input that is scanned and stored in variable 'a',then it is printed out 2 using printf(). Note that after if statement i used set of braces({}) to show that next statement to be executed after if. If the braces are omitted then error -"; statement missing" is produced.
The above program can be re-written as follows:
main()
{
int a;
clrscr();
if(scanf("%d",&a))
;
if(printf("%d"),a)
;
}
main()
{
int a;
clrscr();
if(scanf("%d",&a))
{}
if(printf("%d"),a)
{}
}
output:
2
2
Here in output,i entered 2 is given as input that is scanned and stored in variable 'a',then it is printed out 2 using printf(). Note that after if statement i used set of braces({}) to show that next statement to be executed after if. If the braces are omitted then error -"; statement missing" is produced.
The above program can be re-written as follows:
main()
{
int a;
clrscr();
if(scanf("%d",&a))
;
if(printf("%d"),a)
;
}
Monday, September 6, 2010
Execute both if and else statements
There are two ways to execute both if and else statements.
1.
output:
if loop else loop
In the above statement note that there is a semi-colon (;) in the else statement. This statement is called as NULL statement in 'C'.
The above program becomes:
2.
if(printf("if")==0)
printf(" if");
else
printf(" else");
output:
if else
In the statement-2, the printf which is inside the if condition is executed. Generally if executes the statement which is given as condition, so executes the print statement and then checks it is equal to 0, here condition becomes false. When condition comes false else is executed.
In this above step-2 the print statement which is given inside the if loop is executed. So the question is:
write the condition such that your output will be:
Hello world
1.
if(1)
printf("if loop");
else;
printf(" else loop");output:
if loop else loop
In the above statement note that there is a semi-colon (;) in the else statement. This statement is called as NULL statement in 'C'.
The above program becomes:
if(1)
printf("if loop");
else
;
printf(" else loop");;
2.
if(printf("if")==0)
printf(" if");
else
printf(" else");
output:
In the statement-2, the printf which is inside the if condition is executed. Generally if executes the statement which is given as condition, so executes the print statement and then checks it is equal to 0, here condition becomes false. When condition comes false else is executed.
if(condition)
printf("Hello");
else
printf(" world");
write the condition such that your output will be:
Hello world
Sunday, March 14, 2010
Error:Disabled by your administrator
On my system virus attack and cancelled all system privileges.Including regedit,gpedit.msc,control panel. Though i logged into "Administrator" i got an error:"All rights are disabled by your administrator". Then i installed anti-virus program and removed all virus and Trojan programs from computer. Still my problem not solved then i searched i found a answer for it..My solution for this problem is as follows:
Go to Start->run in that type the following
"REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableRegistryTools /t REG_DWORD /d 0 /f"
Remove the double quotes. Here i used to quote that command. After enter on your press enter. You will realize something runs on your system..
Now run Group editor policy on your computer by typing gpedit.msc under run. In that select
User Configuration->Administrative Templates->System
under System you will found "Prevent access to registry editing tools" right click on it select properties.
on properties window Prevent access to registry editing tools option select Not Configured.
If its already Not Configured option is selected. Select Enable click ok then right click on the Prevent access to registry editing tools now set the properties to Not Configured. Now run regedit on your system. Likewise run control panel on your computer.
Go to start->run gpedit.msc.In that select
User Configuration->Administrative Templates->Control Panel.
under control panel select "Prohibit access to control panel"
on properties window Prohibit access to control panel option select Not Configured.
If its already Not Configured option is selected. Select Enable click ok then right click on the Prohibit access to control panel now set the properties to Not Configured.
Go to Start->run in that type the following
"REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableRegistryTools /t REG_DWORD /d 0 /f"
Remove the double quotes. Here i used to quote that command. After enter on your press enter. You will realize something runs on your system..
Now run Group editor policy on your computer by typing gpedit.msc under run. In that select
User Configuration->Administrative Templates->System
under System you will found "Prevent access to registry editing tools" right click on it select properties.
on properties window Prevent access to registry editing tools option select Not Configured.
If its already Not Configured option is selected. Select Enable click ok then right click on the Prevent access to registry editing tools now set the properties to Not Configured. Now run regedit on your system. Likewise run control panel on your computer.
Go to start->run gpedit.msc.In that select
User Configuration->Administrative Templates->Control Panel.
under control panel select "Prohibit access to control panel"
on properties window Prohibit access to control panel option select Not Configured.
If its already Not Configured option is selected. Select Enable click ok then right click on the Prohibit access to control panel now set the properties to Not Configured.
Subscribe to:
Posts (Atom)