GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  CSC
Go To First  |  Previous Question  |  
 CSC  |  Question 7 of 7    Print  
char str[10];
int i;
for(i=0;i<=9;i++)
scanf("%s",&str[i]);
for(i=0;i<=9;i++)
printf("%c",str[i]);

What will be the difference if we use %c instead of %s in scanf, give reason also

  
Total Answers and Comments: 2 Last Update: February 09, 2009     Asked by: Mohit thaliyal 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 27, 2008 05:53:12   #1  
Ishan Sharma Member Since: July 2008   Contribution: 4    

RE: char str[10];int i;for(i=0;i

With s it will take 9 name or words but prints only starting alphabets...and with c it will take characters and prints 9 characters which have entered....

for eg:-

with s it can take hello going sitting etc till 9 words but prints h g s i.e starting letter

with c it will take hello and going as characters i.e it will consider each letter of hello and going as a independent unit and prints hellogoing as sitting will be out of it memory size


 
Is this answer useful? Yes | No
February 09, 2009 03:48:54   #2  
kapildeverampu Member Since: February 2009   Contribution: 1    

RE: char str[10];int i;for(i=0;i
If you use
scanf( s &str[i]); then you can input 10 names like ravi rama kapil ..etc. But only the first letter of each names will be stored
It you use
scanf( c &str[i]); then you will be able to input only 10 characters.

 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : The term collision domain is defined as a logical network segment. In a collision domain, the packets of data collide with one another when they are sent on a medium which is shared. One of the most well-known examples of a collision domain is the Ethernet ...
Read Answers (2) | Asked by : hafiZ muhammad junaid

In written they give two tests:-1) quant/aptitude/logical ppr 40ques in 40minutes2) technical test 75question in 40min apti/quant/logicalit was a very tough test i hav given test of 6-7 companies but csc 
View Question | Asked by : ajeet

Latest Answer : If you usescanf("%s",&str[i]); then you can input 10 names like ravi, rama, kapil ..etc.  But only the first letter of each names will be storedIt you usescanf("%c",&str[i]); then you will be able to input only 10 characters. ...
Read Answers (2) | Asked by : Mohit thaliyal


 Sponsored Links

 
Related Articles

printf() Function Return Value

What is the return value from printf() function? printf function always returns the number of characters printed. Let us understand this with an example: main() { int a=10; printf(&quot;%d&quot;,printf(&quot;%d %d %d&quot;, a,a,a)); } In this above program the inner printf i
 

What is difference between call by value and call by reference in function?

The arguments passed to function can be of two types 1. Values passed 2. Address passed The first type refers to call by value and the second type refers to call by reference. For instance consider program1 main() { int x=50, y=70; interchange(x,y); printf(&ldquo;x=%d y=%d&rdquo;,x,
 

What are the Format Specifiers used with printf?

There are several format specifiers available in printf. The format specifier used varies depending on the data type used for printing. The given below are some of the format specifiers used with printf in C program. For integer data type the format specifier used with printf is %d or %i For float
 

printf and sprintf

What is the difference between printf and sprintf? sprintf: Writes formatted data to a character string in memory instead of stdout Syntax of sprintf is: #include &lt;stdio.h&gt; int sprintf (char *string, const char *format [,item [,item]...]); Here, String refers to the pointer to a
 

Difference between Scholarship and Grant

Difference between Scholarship and Grant While both scholarships and grants allow students to pay for their tuition without having to pay the money back there are a number of key differences between the two Knowing the difference between grants and scholarship will make it much easier for students t
 

The Difference Between Data Mart and Data Warehouse

The Difference Between Data Mart and Data Warehouse The biggest decision facing most IT managers today is whether or not they should construct the data mart before the data warehouse Many vendors will tell you that data warehouses are hard to build as well as expensive mosgoogle If you listen to som
 

Related Categories
Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape