answersLogoWhite

0

What is better int or str?

User Avatar

Anonymous

16y ago
Updated: 8/17/2019

It depends on your game and your class.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

To display string in a title case in c?

#include<stdio.h> #include<conio.h> #include<string.h> int main() { int tmp,i; char str[30]; printf("Enter any string: "); gets(str); for(i=0; str[i]!='\0'; i++) { if(str[i-1]==' ' i==0) { if(str[i]>='a' && str[i]<='z') str[i]=str[i]-32; else if(str[i]>='A' && str[i]<='Z') str[i]=str[i]+32; } printf("%c",str[i]); } getch(); return 0;}


How do you toggle case of string in c code. Example is TogGle will turn into tOGgLE?

#include<stdio.h> int main() { char str[100]; int i; printf("Please enter a string: "); // gets(str); // fgets is a better option over gets to read multiword string . fgets(str, 100, stdin); // Following can be added for extra precaution for '\n' character // if(str[length(str)-1] == '\n') str[strlen(str)-1]=NULL; for(i=0;str[i]!=NULL;i++) { if(str[i]>='A'&&str[i]<='Z') str[i]+=32; else if(str[i]>='a'&&str[i]<='z') str[i]-=32; } printf("String in toggle case is: %s",str); return 0; }


Accept a string from user and find out all rotation of string in 'C'?

#include<stdio.h> void rotate(int index); int main() { char str[50]; gets(str); for(i=0;i<strlen(str);i++) { rotate(i,strlen(str)); } } void rotate(int index,int len) { for(j=index;j<len;j++) printf("%c",*(str+j)); for(j=0;j<index;j++) printf("%c",*(str+j)) printf("\n"); }


Write a program to encrypt a string and decrypt it using your own method of encryption and decryption.?

We'll use a simple method of encryption: xor encryption // same function used to both encrypt and decrypt void crypt(char *str) { const int key = 0x86; // crypt each individual character of str int i; const int length = strlen(str); for(i = 0; i < strlen(str); ++i) { str[i] = str[i] ^ key; } }


What is a C program to calculate the number of characters in a string?

#include<stdio.h> int Strlen (const char* str) { if (!str) return -1; /* invalid argument */ int count; count=0; while (*str++) ++count; return count; } int main (void) { char str[1024]; scanf ("Enter a string: %s\n", str); printf ("Length of string: %d\n", Strlen(str)); return 0; }


write aprogramme to display vowels in c?

Here's a simple C program to display vowels from a given string: #include <stdio.h> int main() { char str[100]; printf("Enter a string: "); fgets(str, sizeof(str), stdin); printf("Vowels in the string: "); for (int i = 0; str[i] != '\0'; i++) { if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u' || str[i] == 'A' || str[i] == 'E' || str[i] == 'I' || str[i] == 'O' || str[i] == 'U') { printf("%c ", str[i]); } } return 0; } This program prompts the user for a string, then iterates over each character to check if it's a vowel, and displays the vowels found.


Program to count the brackets in a string?

// Let's assume you want to search for all square brackets [] public static int getBracketCount(final String str) { int bracketCount = 0; // Iterate through each character in str. for (final char ch : str.toCharArray()) { // If the current character is a bracket, increase bracketCount. switch (ch) { case '[': case ']': ++bracketCount; } } return bracketCount; } // Let's assume you want to search for all square brackets [] int getBracketCount(const char* str) { int bracketCount = 0; // Iterate through each character in str. int i= 0; while( str[i] != '\0' ) { switch(str[i]) { case '[': case ']': ++bracketCount; } ++i; } return bracketCount ; }


Write a c program to reverse string using static implementation of stack?

#include#include#includeint main(){char str[100];int i,temp;printf("Enter any string : ");gets(str);for(i=0; str[i]!=NULL; i++){if(str[i+1]==' ' str[i+1]==NULL){for(temp=i; temp>=0 && str[temp]!=' '; temp--)printf("%c", str[temp]);}printf(" ");}getch();return 0;}


Weite a your own progrem to find a length of string without using library function?

int mystrlen (char* str) { int len = 0; while (*str++ != '\0') len++; return len; }


Program of word sorting from string in c lang?

#include<stdio.h> #include<conio.h> #include<string.h> void sort(char [100][100], int); void main() { char str[100][100]; int n, k; clrscr(); printf("Enter number of words:"); scanf("%d",&n); for(k=0;k<n;k++) { printf("Enter %d word ", k+1); scanf("%s",str[k]); } sort(str, n); getch(); } void sort(char str[100][100], int n) { int i, j; char temp[100]; for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { if(strcmpi(str[i],str[j])>0) { strcpy(temp,str[i]); strcpy(str[i],str[j]); strcpy(str[j],temp); } } } printf("The sorted out data isn"); for(i=0;i<n;i++) { printf("%st", str[i]); } }


Write a c program to find vowels in a character array?

#include <stdio.h> #include <stdlib.h> #include <string.h> main (int argc,char **argv) { char *a,*b,c; int t,e; if (argc<2) return(0); a=argv[1]; b=a; e=strlen(b); for (t=0;t<=e;t++) { c = *b; if (c>='A'&&c<='Z') c -= 'A'-'a'; if (c=='a'c=='e'c=='i'c=='o'c=='u') b++; else *a++ = *b++; } printf ("%s\n",argv[1]); return(0); }


How do you convert number to words in Indian currency of crystal report?

Here is the code to convert number to word format in java as per the Indian number system through user input. It works up to 999999999. import java.util.*; public class NumtoWord { public static void main(String[] args) { String a; Scanner s = new Scanner(System.in); System.out.print("Enter a Number : "); a = s.next(); int b = a.length(); String str[] = {"1","One","2","Two","3","Three","4","Four","5","Five","6","Six", "7","Seven","8","Eight","9","Nine","10","Ten","11","Eleven","12","Twelve","13", "Thirteen","14","Forteen","15","Fifteen","16","Sixteen","17","Seventeen", "18","Eighteen","19","Nineteen","20","Twenty","30","Thirty","40","Fourty", "50","Fifty","60","Sixty","70","Seventy","80","Eighty","90","Ninty","100", "Hundred"}; System.out.println(""); if (b==9) { String s1= a.substring(0,1); String s2= a.substring(1,2); String s3= a.substring(2,3); String s4= a.substring(3,4); String s5= a.substring(4,5); String s6= a.substring(5,6); String s7= a.substring(6,7); String s8= a.substring(7,8); String s9= a.substring(8,9); String s10= a.substring(0,2); String s11= a.substring(2,4); String s12= a.substring(4,6); String s14= a.substring(7,9); { if (s10.equals("00")) System.out.print(""); else if (s1.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s10)) System.out.print("\n" + str[r+1] + " Crore "); } else { { for (int i=0;i<=40;i++) if (str[i].equals(s1)) System.out.print("\n" + str[i+37] + " "); } { if(s2.equals("0")) { System.out.print("Crore "); } else for (int j=0;j<=40;j++) { if (str[j].equals(s2)) System.out.print(str[j+1] + " Crore "); } } } } { if (s11.equals("00")) System.out.print(""); else if (s3.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s11)) System.out.print(str[r+1] + " Lacks "); } else { { for (int k=0;k<=38;k++) if (str[k].equals(s3)) System.out.print(str[k+37] + " "); } { if(s4.equals("0")) { System.out.print("Lacks "); } else for (int l=0;l<=38;l++) { if (str[l].equals(s4)) System.out.print(str[l+1] + " Lacks "); } } } } { if (s12.equals("00")) System.out.print(""); else if (s5.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s12)) System.out.print(str[r+1] + " Thousand "); } else { { for (int m=0;m<=38;m++) if (str[m].equals(s5)) System.out.print(str[m+37] + " "); } { if(s6.equals("0")) { System.out.print("Thousand "); } else for (int n=0;n<=38;n++) { if (str[n].equals(s6)) System.out.print(str[n+1] + " Thousand "); } } } } { for (int o=0;o<=40;o++) if (str[o].equals(s7)) System.out.print(str[o+1] + " Hundred "); } { if (s14.equals("00")) System.out.print(""); else if (s8.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s14)) System.out.print(str[r+1]); System.out.print("\n"); } else { for (int p=0;p<=40;p++) if (str[p].equals(s8)) System.out.print(str[p+37]); for (int q=0;q<=40;q++) { if (str[q].equals(s9)) System.out.print(" " + str[q+1]); } } System.out.print("\n"); } } else if (b==8) { String s1= a.substring(0,1); String s2= a.substring(1,2); String s3= a.substring(2,3); String s4= a.substring(3,4); String s5= a.substring(4,5); String s6= a.substring(5,6); String s7= a.substring(6,7); String s8= a.substring(7,8); String s10= a.substring(1,3); String s11= a.substring(3,5); String s12= a.substring(6,8); { if (s1.equals("0")) System.out.print(""); else for (int i=0;i<=40;i++) if (str[i].equals(s1)) System.out.print("\n" + str[i+1] + " Crore "); } { if (s10.equals("00")) System.out.print(""); else if (s2.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s10)) System.out.print(str[r+1] + " Lacks "); } else { { for (int k=0;k<=38;k++) if (str[k].equals(s2)) System.out.print(str[k+37] + " "); } { if(s3.equals("0")) { System.out.print("Lacks "); } else for (int l=0;l<=38;l++) { if (str[l].equals(s3)) System.out.print(str[l+1] + " Lacks "); } } } } { if (s11.equals("00")) System.out.print(""); else if (s4.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s11)) System.out.print(str[r+1] + " Thousand "); } else { { for (int m=0;m<=38;m++) if (str[m].equals(s4)) System.out.print(str[m+37] + " "); } { if(s5.equals("0")) { System.out.print("Thousand "); } else for (int n=0;n<=38;n++) { if (str[n].equals(s5)) System.out.print(str[n+1] + " Thousand "); } } } } { for (int o=0;o<=40;o++) if (str[o].equals(s6)) System.out.print(str[o+1] + " Hundred "); } { if (s12.equals("00")) System.out.print(""); else if (s7.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s12)) System.out.print(str[r+1]); System.out.print("\n"); } else { for (int p=0;p<=40;p++) if (str[p].equals(s7)) System.out.print(str[p+37]); for (int q=0;q<=40;q++) { if (str[q].equals(s8)) System.out.print(" " + str[q+1]); } } System.out.print("\n"); } } else if (b==7) { String s1= a.substring(0,1); String s2= a.substring(1,2); String s3= a.substring(2,3); String s4= a.substring(3,4); String s5= a.substring(4,5); String s6= a.substring(5,6); String s7= a.substring(6,7); String s10= a.substring(0,2); String s11= a.substring(2,4); String s12= a.substring(5,7); { if (s10.equals("00")) System.out.print(""); else if (s1.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s10)) System.out.print(str[r+1] + " Lacks "); } else { { for (int k=0;k<=38;k++) if (str[k].equals(s1)) System.out.print(str[k+37] + " "); } { if(s2.equals("0")) { System.out.print("Lacks "); } else for (int l=0;l<=38;l++) { if (str[l].equals(s2)) System.out.print(str[l+1] + " Lacks "); } } } } { if (s11.equals("00")) System.out.print(""); else if (s3.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s11)) System.out.print(str[r+1] + " Thousand "); } else { { for (int m=0;m<=38;m++) if (str[m].equals(s3)) System.out.print(str[m+37] + " "); } { if(s4.equals("0")) { System.out.print("Thousand "); } else for (int n=0;n<=38;n++) { if (str[n].equals(s4)) System.out.print(str[n+1] + " Thousand "); } } } } { for (int o=0;o<=40;o++) if (str[o].equals(s5)) System.out.print(str[o+1] + " Hundred "); } { if (s12.equals("00")) System.out.print(""); else if (s6.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s12)) System.out.print(str[r+1]); System.out.print("\n"); } else { for (int p=0;p<=40;p++) if (str[p].equals(s6)) System.out.print(str[p+37]); for (int q=0;q<=40;q++) { if (str[q].equals(s7)) System.out.print(" " + str[q+1]); } } System.out.print("\n"); } } else if (b==6) { String s1= a.substring(0,1); String s2= a.substring(1,2); String s3= a.substring(2,3); String s4= a.substring(3,4); String s5= a.substring(4,5); String s6= a.substring(5,6); String s10= a.substring(1,3); String s11= a.substring(4,6); { if(s1.equals("0")) System.out.print(""); else { for (int j=0;j<=40;j++) if (str[j].equals(s1)) System.out.print(str[j+1] + " Lacks "); } } { if (s10.equals("00")) System.out.print(""); else if (s2.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s10)) System.out.print(str[r+1] + " Thousand "); } else { { for (int m=0;m<=40;m++) if (str[m].equals(s2)) System.out.print(str[m+37] + " "); } { if(s3.equals("0")) { System.out.print("Thousand "); } else for (int n=0;n<=38;n++) { if (str[n].equals(s3)) System.out.print(str[n+1] + " Thousand "); } } } } { if(s4.equals("0")) System.out.print(""); else { for (int o=0;o<=40;o++) if (str[o].equals(s4)) System.out.print(str[o+1] + " Hundred "); } } { if (s11.equals("00")) System.out.print(""); else if (s5.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s11)) System.out.print(str[r+1]); System.out.print("\n"); } else { for (int p=0;p<=40;p++) if (str[p].equals(s5)) System.out.print(str[p+37]); for (int q=0;q<=40;q++) { if (str[q].equals(s6)) System.out.print(" " + str[q+1]); } } System.out.print("\n"); } } else if (b==5) { String s1= a.substring(0,1); String s2= a.substring(1,2); String s3= a.substring(2,3); String s4= a.substring(3,4); String s5= a.substring(4,5); String s10= a.substring(0,2); String s11= a.substring(3,5); { if (s10.equals("00")) System.out.print(""); else if (s1.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s10)) System.out.print(str[r+1] + " Thousand "); } else { { for (int m=0;m<=38;m++) if (str[m].equals(s1)) System.out.print(str[m+37] + " "); } { if(s2.equals("0")) { System.out.print("Thousand "); } else for (int n=0;n<=38;n++) { if (str[n].equals(s2)) System.out.print(str[n+1] + " Thousand "); } } } } { for (int o=0;o<=40;o++) if (str[o].equals(s3)) System.out.print(str[o+1] + " Hundred "); } { if (s11.equals("00")) System.out.print(""); else if (s4.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s11)) System.out.print(str[r+1]); System.out.print("\n"); } else { for (int p=0;p<=40;p++) if (str[p].equals(s4)) System.out.print(str[p+37]); for (int q=0;q<=40;q++) { if (str[q].equals(s5)) System.out.print(" " + str[q+1]); } } System.out.print("\n"); } } else if (b==4) { String s1= a.substring(0,1); String s2= a.substring(1,2); String s3= a.substring(2,3); String s4= a.substring(3,4); String s10= a.substring(2,4); { if(s1.equals("0")) System.out.print(""); else { for (int j=0;j<=40;j++) if (str[j].equals(s1)) System.out.print(str[j+1] + " Thousand "); } } { if(s2.equals("0")) System.out.print(""); else { for (int o=0;o<=40;o++) if (str[o].equals(s2)) System.out.print(str[o+1] + " Hundred "); } } { if (s10.equals("00")) System.out.print(""); else if (s3.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s10)) System.out.print(str[r+1]); System.out.print("\n"); } else { for (int p=0;p<=40;p++) if (str[p].equals(s3)) System.out.print(str[p+37]); for (int q=0;q<=40;q++) { if (str[q].equals(s4)) System.out.print(" " + str[q+1]); } } System.out.print("\n"); } } else if (b==3) { String s1= a.substring(0,1); String s2= a.substring(1,2); String s3= a.substring(2,3); String s10= a.substring(1,3); { if(s1.equals("0")) System.out.print(""); else { for (int o=0;o<=40;o++) if (str[o].equals(s1)) System.out.print(str[o+1] + " Hundred "); } } { if (s10.equals("00")) System.out.print(""); else if (s2.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s10)) System.out.print(str[r+1]); System.out.print("\n"); } else { for (int p=0;p<=40;p++) if (str[p].equals(s2)) System.out.print(str[p+37]); for (int q=0;q<=40;q++) { if (str[q].equals(s3)) System.out.print(" " + str[q+1]); } } System.out.print("\n"); } } else if (b==2) { String s1= a.substring(0,1); String s2= a.substring(1,2); String s10= a.substring(0,2); { if (s10.equals("00")) System.out.print(""); else if (s1.equals("1")) { for (int r=0;r<=40;r++) if (str[r].equals(s10)) System.out.print(str[r+1]); System.out.print("\n"); } else { for (int p=0;p<=40;p++) if (str[p].equals(s1)) System.out.print(str[p+37]); for (int q=0;q<=40;q++) { if (str[q].equals(s2)) System.out.print(" " + str[q+1]); } } System.out.print("\n"); } } else if (b==1) { String s1= a.substring(0,1); for (int q=0;q<=40;q++) if (str[q].equals(s1)) System.out.print(" " + str[q+1]); } System.out.println("\n"); } } // By Abhishek Singh (abhishek_singh_rajawat@yahoo.co.in).