- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
13 Posted Topics
Q.Write a function to concatenate to input strings into one large string and display the result. I know how to do this using strcat but not without it. Also can't use pointers. Please help!!
[quote=Eko;283842]Very nice tip :) You were right , it's much easier and simple with isalpha() Here's the new version: [code] #include <stdio.h> #include <ctype.h> #include <string.h> int main() { char string[100]; int i,found=0; printf("Type a string : "); gets(string); for(i=0;i<strlen(string);i++) if( isalpha(string[i])) found++; printf("Number of characters: %d\n",found); return 0; } …
Q.Create an equivalent of four function calculator. The program should request the user to enter two numbers and an operator. It should carry out specified arithmetic operation on the two numbers( using switch case).After displaying the result, the program should ask the user if he/she wants to do another calculation.If …
I whole heartedly agree with that [:)] But point in question is, does that really happen(mercy passing)?
[quote=dcc;368644]Paris Hilton was arrested for driving under the influence and as I understand it she was also driving on an expired drivers license. You can read about it [URL="http://www.cnn.com/2006/SHOWBIZ/TV/09/07/parishilton/"]here[/URL].[/quote] Right you are. But she was going to get only a 45 day jail term and now even that has been …
Q.Using recursive function,reverse a string. Solution I tried [CODE] #include<stdio.h> #include<string.h> char reverse(char *ptr,int length) { return ptr[0]=ptr[length-1]; while(*ptr!='\0') reverse(ptr+1,length-2); } int main(void) { char string[40],answer; printf("Enter string\n"); gets(string); answer=reverse(string,strlen(string)); printf("%c",answer); return 0; } [/CODE] It gives an error sayin 'Unreachable code in function reverse(char near*,int)' because of the line …
I want to know when it is necessary to include a return statemnt in one's code and also what is the difference between recursion and iteration?
You should post your problem and the code you tried right here. Why else is this called a forum? Don't worry, there a lot of people who'll help you.So post asap.
Q.Write a program to input data in an array.Compute the sum and average.Then count the number of values greater than the average and lesser than the average.Print the average,sum and the two counts. Solution I tried [CODE] #include<stdio.h> int main(void) { int X[10],i,lesser=0,greater=0,sum=0; float avg=0; for(i=0;i<10;i++) { printf("Enter number\n"); scanf("%d",&X[i]); …
Q. WAPC to read a string into an aaray and capitalize the first character of every word in the input. Solution I tried [CODE] #include<stdio.h> int main(void) { char string[50]; char *ptr; printf("Enter string\n"); fgets(string,sizeof string,stdin); printf("string= \"%s\"\n",string); for(ptr=string;string!='\0';ptr++) { if(*ptr==' ') { ptr++; *ptr=*ptr-32; } } printf("The new string …
Q.Write a function to accept a main string, one search string and one replace string. Replace the first occurence of search string in main string by replace string{assume the length of search and replace string is same). Solution I tried [CODE] #include<stdio.h> #include<conio.h> void main() { char mai[80],search[40],replace[40]; int i,j,k,l; …
Q.Write a function to accept 20 characters and display whether each character input is a digit, lower case letter or upper case letter. Solution I tried [code=c] #include<stdio.h> #include<conio.h> int main() { char inp; int i; clrscr(); for(i=0;i<20;i++) { printf("Enter a character\n"); scanf("%c",&inp); if(inp>='0'&& inp<='9') { printf("It is a digit\n"); …
Q.Write a function to accept upto 25 numbers and display highest and lowest number along with all the numbers. Solution I tried [code=c] #include<stdio.h> #include<conio.h> void main() { int array[25],low,high; int i; clrscr(); do { printf("Enter a number(0 to terminate)\n"); scanf("%d",&array[i]); }while(array[i]!=0); i=0; low=high=array[0]; while(array[i]!=0) { if (low>array[i]) low=array[i]; else …
The End.
IwalkAlone