Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

emonyi / IAX0583

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit 4b64104a authored 6 years ago by emonyi's avatar emonyi
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

Upload New File

parent a53f4300 master
Hide whitespace changes
Inline Side-by-side
Showing with 52 additions and 0 deletions
  • lab9/task3.c
lab9/task3.c 0 → 100644
View file @ 4b64104a
#include <stdio.h>
#include <string.h>
int ident(char str[5]);
int convertToInteger(char str[5]);
int main(){
char input[5];
int count = 0;
do{
if(count > 0){
printf("This is not a number!\n");
}
puts("Enter a 5 digit number: ");
scanf("%s", input);
printf("String: %s", input);
printf("\n");
count ++;
}while(ident(input) != 5);
printf("Integer: %d\n", convertToInteger(input));
return 0;
}
int ident(char str[5]){
int flag;
int result = 0;
for(int i = 0; i < 5; i++){
flag = 0;
for(int j = 48; j <= 57; j++){
if(str[i] == j){
flag = 1;
break;
}
}
result = result + flag;
}
return result;
}
int convertToInteger(char str[5]){
int i, len;
int result=0;
len = 5;
for(i=0; i<len; i++){
result = result * 10 + ( str[i] - '0' );
}
return result;
}
This diff is collapsed. Click to expand it.
  • Write
  • Preview
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment