Total Pageviews

Wednesday 6 July 2016

C program for Series - 2,3,5,3,5,8,4,7,11,5,9,14..

Input-10
Output-2 3 5 3 5 8 4 7 11 5 9 14 6 11 17 7 13 20 8 15 23 9 17 26 10 19 29

PROGRAM

#include <iostream>
using namespace std;

int main() {

int n;
cin>>n;
int count=1;
for(int i=2;i<=n;i++){
   int l = i;
   cout<<l<<" ";
   l+=count;
   cout<<l<<" ";
   count++;
   l+=count;
   cout<<l<<" ";
}
return 0;
}

OUTPUT-

Sunday 3 July 2016

Delete a vowel from a String- C Program

Input- Absolutely

Output- bsltly

PROGRAM

//Delete vowels from a String

#include<stdio.h>
#include<string.h>
int main()
{
char s[20];
int i=0,j=0;
scanf("%s",&s);
for(i=0;i<=strlen(s);i++)
{
if((s[i]=='a')||(s[i]=='e')||(s[i]=='i')||(s[i]=='o')||(s[i]=='u'))
s[i]=' ';
else
s[j++]=s[i];
}
printf("%s",s);
return 0;  
}

OUTPUT

"strcmp" C- Example

Input- red
Output-Its a Dusk

Input-green
Output-Its a Dawn

Input- #Any other Color
Output-Invalid Input

--Program--

#include<stdio.h>
int main()
{
char s[20];
scanf("%s",&s);
if(strcmp(s,"blue")==0)
printf("Its a Dawn");
else if(strcmp(s,"red")==0)
printf("Its a dusk");
else printf("Invalid Input");
return 0;

}

OUTPUT